new Vue({
	el: '#app',
	data: function () {
		return {
			loading:false,//进去的加载中显示
			host: window.location.protocol+'//'+window.location.host,
			headers:{
				'app-id':'992020022270580001',
				'appId':'992020022270580001',
				'TRANSACTION-ID':this.uuid(),
				'REQ-TIME':this.getDateYYYYMMDDHHMISS(),
				'SIGN':'',
				'user_id':'-1',
				'communityId':this.communityId,
			},
            communityId:'',
            activeTypeValue: '',
            showPicker: false,
            columnsType: [
                {value:'01',text:'电脑'}
            ],
            message:'',
            fileList: [
            ],
            value1:'',
            value2:'',
            show: false,
			fieldValue: '2-1-1004',
			cascaderValue: '',
			index1:0,
			index2:0,
			index3:0,
            indexId:0,
            options: [
                //   {
                // 	text: '浙江省',
                // 	value: '330000',
                // 	children: [],
                //   },
            ],
            type:'',
		
		}
	},
	created() {
        var localStorageCommunityId=JSON.parse(localStorage.getItem('hc_currentCommunityInfo'))
		if(localStorageCommunityId){
			this.communityId=localStorageCommunityId.communityId?localStorageCommunityId.communityId:this.getUrlParam("communityId");
		}else{
			this.communityId=this.getUrlParam("communityId");
		}
		this.headers.communityId=this.communityId;
        this.type=this.getUrlParam("type");
        console.log(this.type);
        if(this.type=='RJLKBSQ'){
            document.title='农家乐开办申请';
            this.activeTypeValue='农家乐开办申请'

        }else if(this.type=='CMMSGZSQ'){
            document.title='村民名宿改造申请';
            this.activeTypeValue='村民名宿改造申请'
        }
	},
	mounted(){
	},
	filters: {
		subStringThree: function (value) {
			if (!value) return ''
			return value.substring(0,3)
		}
	},
	methods: {
		uuid() {
			let s = [];
			let hexDigits = "0123456789abcdef";
			for (let i = 0; i < 36; i++) {
				s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
			}
			s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
			s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
			s[8] = s[13] = s[18] = s[23] = "-";
	
			let uuid = s.join("");
			return uuid;
		},
		getDateYYYYMMDDHHMISS(){
			let date = new Date();
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let day = date.getDate();
			let hour = date.getHours();
			let minute = date.getMinutes();
			let second = date.getSeconds();
			if (month < 10) {
				month = '0' + month;
			}
			if (day < 10) {
				day = '0' + day;
			}
			if (hour < 10) {
				hour = '0' + hour;
			}
			if (minute < 10) {
				minute = '0' + minute;
			}
			if (second < 10) {
				second = '0' + second;
			}
			return year + "" + month + "" + day + "" + hour + "" + minute + "" + second;
		},
		getUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg); //匹配目标参数
			if (r != null) return unescape(r[2]);
			return null; //返回参数值	  
		},
        onConfirm(value) {
            this.activeTypeValue = value.text;
            this.showPicker = false;
        },

        onOversize(file) {
            console.log(file);
            vant.Toast('文件大小不能超过 1M');
        },
        afterRead(file) {

            file.status = 'uploading';
            file.message = '上传中...';
      
            setTimeout(() => {
              file.status = 'done';
              file.message = '上传完成';
            }, 1000);

        },
        onChange({ value, selectedOptions, tabIndex }) {
			let that=this;
			console.log(value,selectedOptions,tabIndex)
			var unitListChildren=that.options;
			if(unitListChildren && tabIndex==0){
				unitListChildren.forEach(function(item,index) {
					if (value == item.value) {
						that.index2=index;
						console.log('index2',index)
						that.triggerBuildId=value;//楼栋Id
						that.queryUnit()
					}
				});
			}
			if(unitListChildren[that.index2] && tabIndex==1){
				var roomListChildren=unitListChildren[that.index2].children;
				if(roomListChildren){
					roomListChildren.forEach(function(item,index) {
						if (value == item.value) {
							that.index3=index;
							console.log('index3',index)
							that.triggerUnitId=value;//单元Id
							that.queryRoom()
						}
					});
				}
			}
			if(tabIndex==2){
				that.triggerRoomId=value;//房屋Id
			}
			
		},
		onFinish({ selectedOptions }) {
			console.log(this.clickIndex)
			this.show = false;
			this.fieldValue = selectedOptions.map((option) => option.text).join('/');
		},
		//显示选择小区房屋
		clickShow(){
            this.show=true;
		},
        submitBtn(){
            vant.Toast.success('提交成功！');
        }
        
      
	}
});